#ifndef _RPC_CHANNELIMPL_H_
#define _RPC_CHANNELIMPL_H_

#include "rpc_fwd.h"

#pragma once

class RPCChannelImpl : public google::protobuf::RpcChannel
{
public:
    RPCChannelImpl( RPCSysMgr * rpcsysmgr, const std::string & full_name );

    virtual ~RPCChannelImpl() throw();

    virtual void CallMethod( const google::protobuf::MethodDescriptor* method,
                             google::protobuf::RpcController* controller,
                             const google::protobuf::Message* request,
                             google::protobuf::Message * response,
                             google::protobuf::Closure * done );

    void set_result( const char * result_buf, int32_t result_buf_len, const std::string & reason );

    inline const char * get_buf() const {
        return m_rpc_msg_serial_buf.c_str();
    }

    inline int32_t get_buf_len() const {
        return m_rpc_msg_serial_buf.size();
    }

    inline const std::string & get_service_fullname() const {
        return m_service_fullname;
    }

    int32_t wait_result( const Time_Value & delay );

private:
    RPCSysMgr *                     m_rpcsysmgr;
    const std::string               m_service_fullname;
    std::string                     m_rpc_msg_serial_buf;
};

#endif // _RPC_CHANNELIMPL_H_


